<!DOCTYPE html>
<html>
<head>
	<title></title>
	<meta charset="utf-8"/>
</head>
<body>
<input type="checkbox" value="1" class="kk" kk="333" id="kk" /> 
<input type="button" value="2" id="btn"/> 

<div style="width:300px;">
	<ul>
		<li ><span id="time" style="width:80%;display:inline-block;">aaa</span><span>bbb</span></li>
	</ul>
</div>
<canvas id="myCanvas" width="500px" height="400px"></canvas>
<canvas id="myCanvas2"width="400"height="400"style="border:1px solid #c3c3c3;">Yourbrowserdoesnotsupportthecanvaselement.</canvas>
</body>
<script type="text/javascript" src="./js/jquery-1.8.2.js"></script>
<script type="text/javascript" src="js/utils.js"></script>
<!-- <script type="text/javascript" src="js/utils_test.js"></script> -->
<script type="text/javascript">
getCheckInTime('2015-12-18 12:32:32');
function strToDate(timeStr){
	var dateArr = timeStr.split('-');
	var timeArr = [];
	var day = dateArr[2];
	var hour = 0;
	var min = 0;
	var second = 0;
	if(dateArr[2].length>3){
		timeArr = dateArr[2].split(':');
		var dhArr = timeArr[0].split(' ');
		day = dhArr[0];
		hour = dhArr[1];
		min = timeArr[1];
		second = timeArr[2];
	}
	return new Date(dateArr[0],parseInt(dateArr[1])-1,day,hour,min,second);
}
function getCheckInTime(timeStr) {
	var checkInTime = strToDate(timeStr).getTime();
	var days = 0;
	var hours = 0;
	var minutes = 0;
	var seconds = 0;
	var $con = $('#time');
	var pt = function(num){
		return num>9? num:'0'+num;
	}
	if (checkInTime) {
		var d = new Date();
		console.log(d);
		var currentTime = d.getTime();
		var diffTime = parseInt(checkInTime)  - parseInt(currentTime);
		if(diffTime>0){
			days = Math.floor(diffTime/(24*3600*1000));
			var left = diffTime % (24*3600*1000);
			hours = Math.floor(left/(3600*1000));
			var left1 = left % (3600*1000);
			minutes = Math.floor(left1/(60*1000));
			var left2 = left1%(60*1000);
			seconds = Math.floor(left2/1000);
		}
		var t = setInterval(function(){
			if (seconds < 0) {
				seconds = 59;
				minutes--;
			}
	
			if (minutes < 0) {
				minutes = 59;
				hours--;
			}
	
			if (hours < 0) {
				hours = 23;
				days--;
			}
			if(days < 0){
				days = 0;
				hours = 0;
				minutes = 0;
				seconds = 0;
				clearInterval(t);
			}
			$con.html(days+'天'+pt(hours)+'时'+pt(minutes)+'分'+pt(seconds)+'秒');
			console.log('run');
			seconds--;
		},1000);
	}
	$con.html(days+'天'+pt(hours)+'时'+pt(minutes)+'分'+pt(seconds)+'秒');
}
</script>

</html>